Skip to content

feat: add optional songs filter to content creation endpoint#348

Merged
sweetmantech merged 3 commits intotestfrom
feature/song-filtering
Mar 30, 2026
Merged

feat: add optional songs filter to content creation endpoint#348
sweetmantech merged 3 commits intotestfrom
feature/song-filtering

Conversation

@sidneyswift
Copy link
Copy Markdown
Contributor

@sidneyswift sidneyswift commented Mar 26, 2026

Summary

  • Add optional songs field to Zod schema in validateCreateContentBody
  • Pass songs through createContentHandler into triggerCreateContent payload
  • Add songs?: string[] to TriggerCreateContentPayload interface

Test plan

  • All 1553 existing tests pass
  • Verify POST /api/content/create with songs: ["hiccups"] triggers task with song filter
  • Verify omitting songs preserves current behavior

Made with Cursor

Summary by CodeRabbit

Release Notes

  • New Features
    • Content creation now supports specifying songs. Users can optionally provide a list of songs to customize and constrain the content generation process.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Mar 30, 2026 10:52pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The pull request extends the content-creation pipeline to accept and propagate an optional songs field. Request validation now accepts an optional array of song strings, the handler passes this validated data to the content trigger, and the trigger payload interface supports the new field.

Changes

Cohort / File(s) Summary
Song field propagation
lib/content/validateCreateContentBody.ts, lib/content/createContentHandler.ts, lib/trigger/triggerCreateContent.ts
Added optional songs?: string[] field to request validation schema, validated body type, handler payload forwarding, and trigger payload interface. Enables downstream logic to constrain content creation using provided song slugs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🎵 A song field threads through the line,
From validation to trigger so fine,
Through handler it flows, optional and bright,
Building cleaner content pipelines right. 🎶

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Solid & Clean Code ⚠️ Warning Validation pattern for songs field uses z.array(z.string().min(1)).optional() which allows whitespace-only strings, violating established codebase pattern from validateGetTaskRunQuery.ts that applies .trim() before .min(1). This creates data integrity risk and reduces maintainability. Additionally, songs field lacks unit test coverage in both validateCreateContentBody.test.ts and createContentHandler.test.ts. Modify line 28 in validateCreateContentBody.ts to use z.array(z.string().trim().min(1, "song cannot be empty")).optional(). Add unit tests covering valid arrays, whitespace strings, empty arrays, and invalid types.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/song-filtering

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sweetmantech
Copy link
Copy Markdown
Contributor

Preview Deployment Test Results

Deployment URL: recoup-72tulpph2-recoupable-ad724970.vercel.app
Endpoint: POST /api/content/create
Commit: 2225d79

Results: All 4 tests passed ✅

# Test Case Status Details
1 Without songs field (existing behavior) ✅ Pass Returns triggered with runId — existing behavior preserved
2 With songs: ["hiccups"] ✅ Pass Returns triggered with runId — songs accepted and passed through
3 songs as invalid type (string instead of array) ✅ Pass Returns 400: "Invalid input: expected array, received string"
4 songs with empty string [""] ✅ Pass Returns 400: "Too small: expected string to have >=1 characters"

Summary

  • The optional songs field is correctly accepted as string[]
  • Omitting songs preserves existing behavior (no regression)
  • Zod validation correctly rejects invalid types and empty strings
  • The new album-record-store template is recognized and works

Tested by Claude Code against the Vercel preview deployment.

@sweetmantech
Copy link
Copy Markdown
Contributor

Preview Deployment Test Results (Real Artist)

Deployment URL: recoup-72tulpph2-recoupable-ad724970.vercel.app
Endpoint: POST /api/content/create
Artist: 1873859c-dd37-4e9a-9bac-80d3558527a9

Results: All tests passed ✅

# Test Case Status Run ID
1 Without songs (existing behavior) ✅ Pass run_cmndi7qul7u990hn8j2dd6boe
2 With songs: ["hiccups"] ✅ Pass run_cmndi7u9h7xge0uoog9szxbdu
3 songs as invalid type (string) ✅ Pass 400 — "Invalid input: expected array, received string"
4 songs with empty string [""] ✅ Pass 400 — "Too small: expected string to have >=1 characters"

Summary

  • Existing behavior preserved when songs is omitted
  • songs: ["hiccups"] accepted and task triggered successfully
  • Zod validation rejects invalid types and empty strings
  • album-record-store template works correctly

Tested by Claude Code against the Vercel preview deployment with a real artist.

sidneyswift and others added 3 commits March 30, 2026 17:50
Pass through an optional songs array from POST /api/content/create
to the Trigger.dev task so the pipeline can restrict which songs
it picks from.

Made-with: Cursor
Split into separate PR #376 per SRP feedback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sweetmantech
Copy link
Copy Markdown
Contributor

E2E Test Results — songs: ["hiccups"] filter

Run ID: run_cmnds4c0wcdxq0hn6lfg1mlef
Status: Completed
Duration: 3.8 min
Cost: $0.0195

Payload

{
  "artist_account_id": "1873859c-dd37-4e9a-9bac-80d3558527a9",
  "template": "artist-caption-bedroom",
  "lipsync": false,
  "caption_length": "long",
  "upscale": false,
  "songs": ["hiccups"]
}

Results

Step Status
Song filtering (hiccups) Filtered to specified songs
Selected song hiccups.mp3
Clip 0.8s start, 15s duration
Clip lyrics "The worst kind of hangover came from you I woke up with a headache and you in my bed..."
Clip mood Annoyed, Regretful
Image generation View image
Video View final video
Caption "i swear my brain is just a tangled mess of piano melodies and half-formed thoughts at 3 am..."

Summary

  • songs: ["hiccups"] correctly filtered to only the "hiccups" track
  • Full pipeline completed end-to-end: image → video → caption → ffmpeg render
  • Branch rebased onto latest test

Tested by Claude Code against production Trigger.dev deployment.

@sweetmantech sweetmantech merged commit 5961b30 into test Mar 30, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants